$('#logout').on('click', function() {
    var isConfirm = confirm('约定要退出吗');
    if (isConfirm) {
        $.ajax({
            type: 'post',
            url: '/logout',
            success: function() {
                location.href = 'login.html';
            },
            error: function() {
                alert('退出失败');
            }
        });
    }
});

function formDate(date) {
    var date = new Date(date);
    return `${date.getFullYear()}年${date.getMonth() +
        1}月${date.getDate()}日${date.getHours()}时${date.getMinutes()}分${date.getSeconds()}秒`;
}

console.log(userId);
$.ajax({
    type: 'get',
    url: `/users/${userId}`,
    success: function(response) {
        $('.profile .avatar').attr('src', response.avatar);
        $('.profile .name').text(response.nickName);
        $('.profile').show();
    }
});
